package com.zlh123.controller;

import com.zlh123.commom.util.PageResult;
import com.zlh123.commom.util.R;
import com.zlh123.entity.User;
import com.zlh123.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zlh
 * @since 2025-01-13
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;
    //用户列表
    @RequestMapping("/list")
    public R getUserList() {
        return R.ok().data("list",userService.list());
    }
    //分页
    @GetMapping("/findUsersByPage/{page}/{pageSize}")
    public R findByPage(@PathVariable("page") int page,
                        @PathVariable("pageSize") int pageSize) {
        PageResult<User> student=userService.findUsersByPage(page,pageSize);
        return R.ok().data("list",student);
    }
}
